package com.example.javabasic.elasticsearch.booksearch;

import org.elasticsearch.client.Client;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @description es客户端
 * @Author Lin FuYuan
 * @date 2021/6/16
 */
public class EsClient {
    /**
     * 节点
     */
    private String nodes = "http://172.24.116.131:9200";
    /**
     * 集群名称
     */
    private String clusterName;

    private RestHighLevelClient client;

    public RestHighLevelClient client() {
        this.client = new RestHighLevelClient(RestClient.builder(nodes));
        return this.client;
    }

    public void close() throws IOException {
        this.client.close();
    }
}
